home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!usenet
- From: GHouck <hksys@teleport.com>
- Newsgroups: comp.lang.c
- Subject: Re: String Arrays and string parsing
- Date: 20 Feb 1996 10:29:32 GMT
- Organization: systems hk
- Message-ID: <4gc7qc$dm7@maureen.teleport.com>
- References: <31287278.789445@news.inforamp.net>
- NNTP-Posting-Host: ip-pdx04-22.teleport.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- dsheuman@inforamp.net (Danny Heuman) wrote:
- >I have day, month, and year as DDMMMYYYY and would like to parse it
- >out in to DD, MMM, YYYY. I can parse the DD out by using
- >strncpy(into1, from1, 2). I can parse the YYYY out by doing
- >strcpy(into3, from1 + 5). How can I parse out the MMM? Can I use
- >either of these functions that work above, strncpy or strcpy? If so,
- >once parsed, do I have to attach an '\0' to the end of it to keep it
- >as a character string?
- >
- Danny,
- Yes, you can use 'strncpy'. Yes, you have to add zero. Try the following:
-
- strncpy( month,(datestring+2),3 ); /* copy MMM from interior */
- month[3] = '\000'; /* add null terminator */
-
- Yours, Geoff Houck
-
-
-
-